package com.nmsl.sn.controller;


import com.nmsl.common.utils.SecurityUtils;
import com.nmsl.sn.domain.Sn;
import com.nmsl.sn.domain.SnPatient;
import com.nmsl.sn.service.ISnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sn/doctor")
public class SnController {

    @Autowired
    private ISnService snService;

    /**
     * 根据医生ID获取挂号的患者列表
     * @param doctorId
     * @return
     */
    @GetMapping("/patients/{doctorId}")
    public List<Sn> getPatientsByDoctorId(@PathVariable("doctorId") Integer doctorId) {

        System.out.println(SecurityUtils.getUserId());
        return snService.getPatientsByDoctorId(doctorId);
    }
    /**
     * 查找员工id
     */
    @GetMapping("/userid")
    public Integer getUsersByUserid() {
        Integer userid = Math.toIntExact(SecurityUtils.getUserId());
        Integer s = snService.findMyUserid(userid);
        System.out.println(s);
        return s;
    }
    /**
     * 查找患者信息
     */
    @GetMapping("/patient/{patientId}")
    public SnPatient getPatientById(@PathVariable("patientId") Integer patientId) {
        return snService.findPatientById(patientId);
    }
}
